home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F42466_testBuildListWhileIntervals.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-02-06  |  3.5 KB  |  101 lines

  1. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  2. xmlns:xalan="http://xml.apache.org/xalan"
  3. xmlns:pGenerator="pGenerator"
  4. xmlns:pController="pController"
  5. xmlns:IntervalParams="IntervalParams"
  6. xmlns:IntegralFunction="IntegralFunction"
  7. exclude-result-prefixes="xsl xalan pGenerator pController IntervalParams IntegralFunction"
  8. >
  9.   <!-- <xsl:import href="buildListWhile.xsl"/> -->
  10.   <xsl:import href="takeWhile.xsl"/> 
  11.   <xsl:import href="take.xsl"/> 
  12.   
  13.    <!-- to be applied on any xml source -->
  14.    
  15.   <xsl:output indent="yes" omit-xml-declaration="yes"/>
  16.   
  17.   <pGenerator:pGenerator/>
  18.   <pController:pController/>
  19.  
  20.   <IntervalParams:IntervalParams>
  21.     <Interval>
  22.         <el>0</el>
  23.         <el>1</el>
  24.     </Interval>
  25.     <IntegralFunction:IntegralFunction/>
  26.   </IntervalParams:IntervalParams>
  27.   
  28.   <xsl:variable name="vMyGenerator" select="document('')/*/pGenerator:*[1]"/>
  29.   <xsl:variable name="vMyController" select="document('')/*/pController:*[1]"/>
  30.   <xsl:variable name="vIntervalParams" select="document('')/*/IntervalParams:*[1]"/>
  31.  
  32.   <xsl:template match="/">
  33.     <xsl:variable name="vrtfResultIntervalList">
  34.       <xsl:call-template name="buildListWhile">
  35.         <xsl:with-param name="pGenerator" select="$vMyGenerator"/>
  36.         <xsl:with-param name="pController" select="$vMyController"/>
  37.         <xsl:with-param name="pParam0" select="$vIntervalParams"/>
  38.         <xsl:with-param name="pContollerParam" select="256"/>
  39.       </xsl:call-template>
  40.     </xsl:variable>
  41.     
  42.     <xsl:variable name="vResultIntervalList"
  43.        select="xalan:nodeset($vrtfResultIntervalList)/*[last()]/*"/>
  44.        
  45.     <xsl:for-each select="$vResultIntervalList">
  46.      <xsl:value-of select="concat(position(), '. ', ., ' ')"/>
  47.     </xsl:for-each>
  48.     
  49.   </xsl:template>
  50.  
  51.   <xsl:template name="listGenerator" match="*[namespace-uri()='pGenerator']">
  52.      <xsl:param name="pList" select="/.."/>
  53.      <xsl:param name="pParams"/>
  54.      
  55.      <xsl:choose>
  56.        <xsl:when test="not($pList)">
  57.            <xsl:copy-of select="$pParams/*[1]/*"/>
  58.        </xsl:when>
  59.        <xsl:otherwise>
  60.          <xsl:variable name="pFun" select="$pParams/*[2]"/>
  61.           
  62.           <xsl:for-each select="$pList[last()]/*[position() != last()]">
  63.            <xsl:variable name="vFx">
  64.              <xsl:apply-templates select="$pFun">
  65.                <xsl:with-param name="pX" select="string(.)"/>
  66.              </xsl:apply-templates>
  67.            </xsl:variable>
  68.            
  69.            <xsl:variable name="vMid" select="following-sibling::*[1]"/>
  70.            
  71.            <xsl:variable name="vF_mid">
  72.              <xsl:apply-templates select="$pFun">
  73.                <xsl:with-param name="pX" select="string($vMid)"/>
  74.              </xsl:apply-templates>
  75.            </xsl:variable>
  76.            
  77.            
  78.            
  79.            <e><xsl:value-of select="."/></e>
  80.            <e><xsl:value-of select="(. + $vMid) div 2"/></e>
  81.          </xsl:for-each>
  82.          <xsl:copy-of select="$pList[last()]/*[last()]"/>
  83.        </xsl:otherwise>
  84.      </xsl:choose>
  85.      
  86.   </xsl:template>
  87.   
  88.   <xsl:template name="listController" match="*[namespace-uri()='pController']">
  89.      <xsl:param name="pList" select="/.."/>
  90.      <xsl:param name="pParams"/>
  91.  
  92.      <xsl:if test="count($pList[last()]/*) <= $pParams">1</xsl:if>
  93.   </xsl:template>
  94.   
  95.   <xsl:template name="myIntegralFn" match="*[namespace-uri()='IntegralFunction']">
  96.     <xsl:param name="pX"/>
  97.     
  98.     <xsl:value-of select="$pX"/>
  99.   </xsl:template>
  100.      
  101. </xsl:stylesheet>